package com.cgnpc.scp.common.bean;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.List;

/**
 * 分页请求对象类<br>
 * 2020-08-04注释，如果想实现json自动转换的时候pageNum, pageSize在设置setter的时候有值，但是获取getter忽悠字段；<br>
 * 以前@com.fasterxml.jackson.annotation.JsonIgnoreProperties(
 * allowGetters = false, // allowGetters=false，Get时忽略字段
 * allowSetters = true, // allowSetters=true，Set时不忽略字段
 * ignoreUnknown = true, // 允许存在未知的字段，有点奇怪，当前版本该属性也失效了
 * value = {"pageNum", "pageSize"}
 * )
 * 能实现，现在不行了<br>
 * 现在在具体字段上添加注解来实现@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Integer pageNum;<br>
 * 如果某个具体的类想返回被忽略的字段，请重写字段属性，例如@JsonProperty(access = JsonProperty.Access.READ_WRITE) private Integer pageSize;<br>
 */
public class MyPageRequest implements Serializable {
    /**
     * 第几页；默认从第1页开始；
     */
    @TableField(exist = false)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Integer pageNum;

    /**
     * 每页的数量
     */
    @TableField(exist = false)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Integer pageSize;

    /**
     * 排序字段<br>
     * 避免被sql注入攻击<br>
     * 建议使用数字[1,2,3]，后台转换成[name asc, age desc, create_time desc]<br>
     */
    @TableField(exist = false)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private List<String> orderByFieldList;

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<String> getOrderByFieldList() {
        return orderByFieldList;
    }

    public void setOrderByFieldList(List<String> orderByFieldList) {
        this.orderByFieldList = orderByFieldList;
    }
}
